package com.consul.test;

import com.consul.test.service.DiscoveryConsulService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


/**
 * https://cloud.spring.io/spring-cloud-consul/reference/html/#spring-cloud-consul-install
 * <p>
 * distribute consul config:
 * https://cloud.spring.io/spring-cloud-consul/reference/html/#spring-cloud-consul-config
 */
@SpringBootApplication
@RestController
@Slf4j
public class ConsulApplication {

    @Resource
    private DiscoveryConsulService discoveryConsulService;

    /**
     * check service status
     *
     * @return
     */
    @GetMapping("/pet/health")
    public String home() {
        discoveryConsulService.getTestConsulService();
        return "Hello world";
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        SpringApplication.run(ConsulApplication.class, args);
    }
}
